# !/usr/bin/env python
# -*- coding: utf-8 -*-
from functools import reduce


def sqrt(n):
    return n ** 2


if __name__ == '__main__':
    s2 = lambda n: n ** 2
    print(s2(3), sqrt(3))

    m1 = map(lambda x: x * x, [y for y in range(7)])
    print(list(m1))

    m2 = filter(lambda x: x % 3 == 0, [1, 2, 3, 4, 5, 6])
    print(list(m2))

    arr = [('b', 3), ('a', 2), ('d', 4), ('c', 1)]
    m3 = sorted(arr, key=lambda x: x[1])
    print(m3)

    m4 = reduce(lambda a, b: '{},{}'.format(a, b), [1, 2, 3, 4, 5])
    print(m4)
    # 默认值
    cc = (lambda a='Boo', b='Too', c='Z00': a+b+c)
    print(cc('Foo'))
